using cjx.ProxySocket;
using System;
using System.Net.Sockets;
using System.Text;
internal sealed class Class2 : Class0
{
	private string string_0;
	private string string_1;
	public Class2(Socket socket_1, string string_2, string string_3) : base(socket_1)
	{
		this.method_10(string_2);
		this.method_12(string_3);
	}
	private byte[] method_6()
	{
		byte[] array = new byte[3 + this.method_9().Length + this.method_11().Length];
		array[0] = 1;
		array[1] = (byte)this.method_9().Length;
		Array.Copy(Encoding.ASCII.GetBytes(this.method_9()), 0, array, 2, this.method_9().Length);
		array[this.method_9().Length + 2] = (byte)this.method_11().Length;
		Array.Copy(Encoding.ASCII.GetBytes(this.method_11()), 0, array, this.method_9().Length + 3, this.method_11().Length);
		return array;
	}
	public override void vmethod_0()
	{
		base.method_0().Send(this.method_6());
		byte[] array = new byte[2];
		for (int num = 0; num != 2; num += base.method_0().Receive(array, num, 2 - num, SocketFlags.None))
		{
		}
		if (array[1] != 0)
		{
			base.method_0().Close();
			throw new ProxyException("Username/password combination rejected.");
		}
	}
	public override void vmethod_1(Delegate0 delegate0_1)
	{
		this.delegate0_0 = delegate0_1;
		base.method_0().BeginSend(this.method_6(), 0, 3 + this.method_9().Length + this.method_11().Length, SocketFlags.None, new AsyncCallback(this.method_7), base.method_0());
	}
	private void method_7(IAsyncResult iasyncResult_0)
	{
		try
		{
			base.method_0().EndSend(iasyncResult_0);
			base.method_3(new byte[2]);
			base.method_0().BeginReceive(base.method_2(), 0, 2, SocketFlags.None, new AsyncCallback(this.method_8), base.method_0());
		}
		catch (Exception exception_)
		{
			this.delegate0_0(exception_);
		}
	}
	private void method_8(IAsyncResult iasyncResult_0)
	{
		try
		{
			base.method_5(base.method_4() + base.method_0().EndReceive(iasyncResult_0));
			if (base.method_4() == base.method_2().Length)
			{
				if (base.method_2()[1] != 0)
				{
					throw new ProxyException("Username/password combination not accepted.");
				}
				this.delegate0_0(null);
			}
			else
			{
				base.method_0().BeginReceive(base.method_2(), base.method_4(), base.method_2().Length - base.method_4(), SocketFlags.None, new AsyncCallback(this.method_8), base.method_0());
			}
		}
		catch (Exception exception_)
		{
			this.delegate0_0(exception_);
		}
	}
	private string method_9()
	{
		return this.string_0;
	}
	private void method_10(string string_2)
	{
		if (string_2 == null)
		{
			throw new ArgumentNullException();
		}
		this.string_0 = string_2;
	}
	private string method_11()
	{
		return this.string_1;
	}
	private void method_12(string string_2)
	{
		if (string_2 == null)
		{
			throw new ArgumentNullException();
		}
		this.string_1 = string_2;
	}
}
